package com.mathset.business.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mathset.bean.Question;
import com.mathset.business.dao.IQuestionDao;
import com.mathset.common.MathsetConstants;
import com.mathset.mybatis.mapper.IQuestionOperation;

@Repository
public class QuestionDao implements IQuestionDao {

	@Autowired
	private IQuestionOperation iQuestionOperation;
	
	public int submitQuestion(Question question) {
		return iQuestionOperation.submitQuestion(question);
	}

	@Override
	public int updateQuestion(Question question) {
		return iQuestionOperation.updateQuestion(question);
	}

	@Override
	public List<Question> retrieveQuestions(int startIndex) {
		Map<String, Integer> paging = new HashMap<String, Integer>();
		paging.put("startIndex", startIndex);
		paging.put("pageSize", MathsetConstants.PAGE_SIZE+1);
		return iQuestionOperation.retrieveQuestions(paging);
	}

	@Override
	public Question selectQuestionById(int id) {
		return iQuestionOperation.selectQuestionById(id);
	}
}
